class Solution {
public:
    int maxDivScore(vector<int>& nums, vector<int>& divisors)
    {
        int ans = INT_MIN;
        int countAns = -1;
        for (int i = 0; i < divisors.size(); i++)
        {
            int count = 0;
            for (int j = 0; j < nums.size(); j++)
                if (nums[j] % divisors[i] == 0) count++;
            if (count > countAns || (count == countAns && divisors[i] < ans))
            {
                ans = divisors[i];
                countAns = count;
            }
        }
        return ans;
    }
};